package org.ediba.siri.core.image.service;

import java.io.InputStream;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.ediba.siri.core.Filter;
import org.ediba.siri.core.image.domain.Image;
import org.ediba.siri.core.image.domain.ImageAlbum;
import org.ediba.siri.core.image.domain.ImageBackup;
import org.ediba.siri.core.image.domain.ImageKeyword;
import org.ediba.siri.core.image.domain.ImageProvider;
import org.ediba.siri.core.test.domain.Imagekeywordtemp;

public interface ImageService {
		
	public class Name{
		public char letter;
		public int number;
		public Name(char letter, int number){
			this.letter = letter;
			this.number = number;
		}
		@Override
		public String toString(){
			return String.valueOf(this.letter) + String.format("%07d", this.number);			
		}
	};
	
	abstract Image create(boolean requestType);
	abstract Image retrieve(int id);
	abstract Image update(Image image);
	abstract boolean delete(int id);
	
	abstract Image updateTimestamp(int id, Date timestamp);
	abstract Image updateRequest(int id, int idRequest);
	
	abstract List<Image> retrieve(Filter filter, Object value, String sort, boolean dir);
	abstract List<Image> retrieve(Filter filter, Object value, String sort, boolean dir, Integer start, Integer limit);
	abstract List<Image> retrieve(Map<Filter,Collection<Object>> filters, String sort, boolean dir);
	abstract List<Image> retrieve(Map<Filter,Collection<Object>> filters, String sort, boolean dir, Integer start, Integer limit);
	abstract int retrieveCount(Map<Filter,Collection<Object>> filters);
	abstract List<Image> retrieve(List<Integer> ids);

	abstract List<Image> retrieveUsed(int idModel);
	
	abstract Map<String,InputStream> retrieveThumb(int id);
	abstract Map<String,InputStream> retrieveMaster(int id);
	abstract List<String> retrieveMasterTypes(int id);
	abstract InputStream retrieveMaster(int id, String type);
	abstract void updateThumb(int id, InputStream inputStream, String type);
	abstract void updateMaster(int id, InputStream inputStream, String type);
	abstract void deleteMaster(int id);
	abstract void deleteMaster(int id, String type);
	abstract void rotateThumb(int id, boolean dir);
	
	/************   ALBUM    *************/
	
	abstract ImageAlbum albumCreate();
	abstract ImageAlbum albumRetrieve(int id);
	abstract ImageAlbum albumUpdate(ImageAlbum imageAlbum);
	abstract boolean albumDelete(int id);
	
	abstract List<ImageAlbum> albumRetrieve();
	
	/************   KEYWORD    *************/

	abstract ImageKeyword keywordCreate(String word);
	abstract ImageKeyword keywordRetrieve(int id);
	abstract ImageKeyword keywordUpdate(ImageKeyword imageKeyword);
	abstract boolean keywordDelete(int id);
	
	abstract List<ImageKeyword> keywordRetrieve(String sort, boolean dir, Integer start, int limit);
	abstract List<ImageKeyword> keywordRetrieve(String word, Integer start, int limit);
	abstract List<ImageKeyword> keywordRetrieveByImage(int idImage);
	abstract List<ImageKeyword> keywordRetrieveByKeyword(int idImageKeyword);
	
	abstract List<ImageKeyword> keywordRetrieve();
	
	@Deprecated
	abstract List<Imagekeywordtemp> imageKeywordTempRetrieve();
	
	/************   PROVIDER    *************/
	
	abstract ImageProvider providerCreate(String name);
	abstract ImageProvider providerRetrieve(int id);
	abstract ImageProvider providerUpdate(ImageProvider imageProvider);
	abstract boolean providerDelete(int id);

	abstract List<ImageProvider> providerRetrieve(String sort, boolean dir, Integer start, int limit);
	abstract List<ImageProvider> providerRetrieve(String name, Integer start, int limit);
	
	/************   BACKUP    *************/
	
	abstract ImageBackup backupCreate(String name);
	abstract ImageBackup backupRetrieve(int id);
	abstract ImageBackup backupUpdate(ImageBackup imageBackup);
	abstract boolean backupDelete(int id);

	abstract List<ImageBackup> backupRetrieve(String sort, boolean dir, Integer start, int limit);
	abstract List<ImageBackup> backupRetrieve(String name, Integer start, int limit);
		
	/************   UTIL    *************/
	
	//abstract Boolean inferType(String fileName);
	abstract Name getNextName(boolean requestType);
	abstract void setNextName(boolean requestType, Name name);
	abstract void massTagging(int idImage);
	
	
}
